#include <string>
#include <map>
#include <iostream>
using namespace std;

class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        if (s.empty())
            return 0;
        int hash[128] = { 0 };
        int len = 0;
        for (int left = 0, right = 0;right < s.size();right++)
        {
            hash[s[right]]++;
            while (hash[s[right]] > 1)
            {
                hash[s[left++]]--;
            }
            len = (right - left + 1) > len ? (right - left + 1) : len;
        }
        return len;
    }
};

int main()
{
    Solution s;
    cout << s.lengthOfLongestSubstring("abcabcbb");
    return 0;
}